var str = "";
var ch = "";
var i;
var _soul = document.getElementById('soul');
var _but = document.getElementsByTagName('button');  

_but[0].onclick = function () {
    str="";
    _soul.innerHTML ="0";
}

_but[1].onclick = function () {
    var j = str.length-1;
    ch = "";
    for (i=0;i<j;i++) {
       ch = ch + str[i];  
    }   
    _soul.innerHTML = ch;
    str = ch;
}

for (var j=2; j<=17 ;j++) {
    (function(j) {
      _but[j].onclick = function () {
        str = str + _but[j].innerHTML;
        _soul.innerHTML = str;
      }
    }(j))
}

      _but[18].onclick = function () {
            _soul.innerHTML = eval(str);
            // str = "";
        }
